package com.itheima.manager;

import com.itheima.domain.SmsHomeAdvertise;
import com.itheima.service.db.SmsHomeAdvertiseService;
import com.itheima.util.R;
import com.itheima.vo.PageBeanVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class SmsHomeAdvertiseManager {
    @DubboReference
    SmsHomeAdvertiseService smsHomeAdvertiseService;

    /**
     * 营销-广告-分页查询广告
     * @param endTime
     * @param name
     * @param pageNum
     * @param pageSize
     * @param type
     * @return
     */
    public R findAdvertiseByPage(String endTime, String name, Integer pageNum, Integer pageSize, Integer type) {
        PageBeanVo pageBeanVo = smsHomeAdvertiseService.findAdvertiseByPage(endTime,name,pageNum,pageSize,type);
        return R.success(pageBeanVo);
    }

    /**
     * 营销-广告-广告详情
     * @param id
     * @return
     */
    public R findAdvertiseInfo(Integer id) {
        SmsHomeAdvertise smsHomeAdvertise = smsHomeAdvertiseService.findAdvertiseInfo(id);
        return R.success(smsHomeAdvertise);
    }

    /**
     * 营销-广告-修改广告
     * @param advertise
     * @param id
     * @return
     */
    public R updateAdvertise(SmsHomeAdvertise advertise, Integer id) {
        smsHomeAdvertiseService.updateAdvertise(advertise,id);
        return R.success(null);
    }

    /**
     * 营销-广告-修改上线|下线状态
     * @param id
     * @param status
     * @return
     */
    public R updateAdvertiseStatus(Integer id, Integer status) {
        smsHomeAdvertiseService.updateAdvertiseStatus(id,status);
        return R.success(null);
    }

    /**
     * 营销-新品-添加广告
     * @param advertise
     * @return
     */
    public R addAdvertise(SmsHomeAdvertise advertise) {
        smsHomeAdvertiseService.addAdvertise(advertise);
        return R.success(null);
    }

    /**
     * 营销-新品-删除广告
     * @param ids
     * @return
     */
    public R deleteAdvertise(List<Integer> ids) {
        smsHomeAdvertiseService.deleteAdvertise(ids);
        return R.success(null);
    }
}
